<?php if ( $menu_item ) : 
	switch ($menu_item['type']) {
		case 'category':
//			$url = $menu_item['url'];
//			$label = $menu_item['label'];
//			break;
		case 'link';
			$url = isset($menu_item['url']) ? $menu_item['url'] : '#';
			$label = $menu_item['label'];
			break;
		case 'image':
			$url = false;
			$label = '<img src="'.$menu_item['url'].'" alt="" />';
			break;
		case 'column':
			$url = false;
			$label = false;
			$open_column = true;
			break;
	}

	if ( !isset($open_column) ) $open_column = false;
	if ( !isset($opened_column) ) $opened_column = false;
	if ( !isset($menu_item_id) ) $menu_item_id = null;
	?>
<li class="menu-type-<?php echo $menu_item['type'] ?> 
	<?php echo isset($menu_item['class']) ? $menu_item['class'] : ''; ?> 
	<?php echo $this->active_menu == $menu_item_id ? 'menu-active' : '' ?>">
	<?php if ( $url ) { echo '<a href="'.$url.'">'; }
	if ( isset($menu_item['numbered']) && $menu_item['numbered'] ) { echo '<span class="numbered">'.$count.'</span>'; };
	echo '<span class="label">' . ($label ? $label : '') . '</span>';
	if ( $url ) { echo '</a>'; }

	if ( $level == 1 && !empty($menu_item['sub_type']) ) {
		$total_columns = count($menu_item['sub_type']);
		echo '<div class="menu-columns menu-columns-'.$total_columns.'">';

		echo '<span class="menu-columns-arrow"></span>';
	}

	// sub
	if ( !empty($menu_item['sub_type']) ) {

		if ( $menu_item['type'] == 'column' ) {
			echo '<div class="menu-column">';
		}

		echo '<ul class="ul-level-'.($level+1).'">';
		$count = 1;
		$subcates = null;
		if(!empty($menu_item['sub_type']))
		{
			//Load sub category for submenu
			$subcates = $menu_item['sub_items'];
		}
		$url_code = null;
		if(!empty($menu_item['sub_url_code'])) $url_code = $menu_item['sub_url_code'];
		foreach ($subcates as $itm) {
			$_menu_item = array('label'=>$itm->category, 'type'=>'link', 'url'=>(!empty($url_code)) ? $itm[$url_code]: "");
			$this->renderPartial('//common/nav_item', array('menu_item' => $_menu_item, 'level' => $level+1, 'opened_column' => $open_column, 'count' => $count++));
		}
		echo '</ul>';
		echo '<span class="ul-helper-level-'.($level+1).'"></span>';

		if ( $menu_item['type'] == 'column' ) {
			echo '</div>';
		}
	}

	if ( $level == 1 && !empty($menu_item['sub_type']) ) {
		echo '</div>';
	}

	?>
</li>
<?php endif; ?>
